<%@include file="/WEB-INF/pages/commons/commons.jsp" %>

<stripes:layout-render name="${_themePath}/basic-layout-without-navbar.jsp" _title="Add Space">

    <stripes:layout-component name="_head">
        <meta name="_uniquePageId_" content="_editSpaceMembership_"/>
    </stripes:layout-component>

    <stripes:layout-component name="_topNav">
        <H1>Space Membership</H1>
        <UL class="gc-topnav-tabs">
            <LI>&nbsp;</LI>
        </UL>
    </stripes:layout-component>


    <stripes:layout-component name="_content">
        <stripes:messages/>
        <h2>Description [<a id="_showDescription" href="#">Show</a>/<a id="_hideDescription" href="#">Hide</a>]</h2>
        <div id="_description">
            Here's where you are able to make a user a member of your space. By making him a member, he'll
            be able to perform stuff like deleting spaces and pages (even though they are not created by him).

            It's something like giving a minuature space administrator, he'd be able to to anything a
            creator of the space will be able to do. So grant with precausions.
            <p/>    
            <p/>
            <p/>
        </div>


        <jsecurity:hasPermission name="space:membership:${actionBean.space.id}">
        <h2>Membership Removal</h2>
        <stripes:url var="url" beanclass="foo.bar.wiki.web.action.space.EditSpaceMembershipActionBean" event="view">
            <stripes:param name="space" value="${actionBean.space.id}"/>
            <stripes:param name="paginationListName" value="spaceMembership_${actionBean.space.id}_members" />
        </stripes:url>
        <stripes:form beanclass="foo.bar.wiki.web.action.space.EditSpaceMembershipActionBean">
            <stripes:errors/>
            <stripes:submit name="removeSpaceMembership">Remove Membership</stripes:submit>
            <stripes:hidden name="space" value="${actionBean.space.id}"/>
            <p/>
            <displaytag:table id="element" name="${actionBean.members}" 
                                  sort="external"
                                  style="width: 100%;"
                                  excludedParams="*"
                                  defaultsort="1"
                                  defaultorder="ascending"
                                  requestURI="${url}"
                                  requestURIcontext="true" >
                    <displaytag:column property="username" sortable="false" sortName="username" title="User Name" />
                    <displaytag:column property="email" sortable="false" sortName="emailAddress" title="Email" />
                    <displaytag:column title="Actions">
                        <stripes:checkbox name="toBeNonMembers" value="${element.id}" id="toBeNonMembers_${element.id}" />    
                    </displaytag:column>
                </displaytag:table>
        </stripes:form>

        <p/>
        <p/>
        <p/>

        <h2>Membership Addition</h2>
        <stripes:url var="url" beanclass="foo.bar.wiki.web.action.space.EditSpaceMembershipActionBean" event="view">
            <stripes:param name="space" value="${actionBean.space.id}"/>
            <stripes:param name="paginationListName" value="spaceMembership_${actionBean.space.id}_nonMembers" />
        </stripes:url>
        <stripes:form beanclass="foo.bar.wiki.web.action.space.EditSpaceMembershipActionBean">
            <stripes:errors/>
            <stripes:submit name="addSpaceMembership">Add Membership</stripes:submit>
            <stripes:hidden name="space" value="${actionBean.space.id}"/>
            <p/>
            <displaytag:table id="element" name="${actionBean.nonMembers}" 
                                  sort="external"
                                  style="width: 100%;"
                                  excludedParams="*"
                                  defaultsort="1"
                                  defaultorder="ascending"
                                  requestURI="${url}"
                                  requestURIcontext="true" >
                    <displaytag:column property="username" sortable="false" sortName="username" title="User Name" />
                    <displaytag:column property="email" sortable="false" sortName="emailAddress" title="Email" />
                    <displaytag:column title="Actions">
                        <stripes:checkbox name="toBeMembers" value="${element.id}" id="toBeMembers_${element.id}"/>   
                    </displaytag:column>
                </displaytag:table>
        </stripes:form>
        </jsecurity:hasPermission>
        <jsecurity:lacksPermission name="space:membership:${actionBean.space.id}">
            Lacks "space:membership:${actionBean.space.id}" permission
        </jsecurity:lacksPermission>
    </stripes:layout-component>

</stripes:layout-render>

